package net.sppan.base.dao;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import net.sppan.base.dao.support.IBaseDao;
import net.sppan.base.entity.ContentUnreviewed;
@Repository
public interface IContentUnreviewedDao  extends IBaseDao<ContentUnreviewed, Long> {

	@Query(value = "FROM ContentUnreviewed where isApproved in(:status)",
			countQuery ="select count(*) from ContentUnreviewed where isApproved in(:status)")
	List<ContentUnreviewed> findContentUnreviewed(@Param("status") String status,Pageable pageable);
	
	@Query(value ="select count(*) from ContentUnreviewed where contentType in(3,4) and allotStatus=0 and isApproved in(:status)")
	Integer  countContenTask(@Param("status") List<String>  status);
    
	@Modifying
	@Query(value="update ContentUnreviewed set allotStatus=:status where dyContentId in(:ids)")
	void updateList(@Param("ids")List<Long> ids,@Param("status") String status);

	@Query(value="from ContentUnreviewed where contentType in(3,4) and allotStatus=0 and isApproved in(:status) ",
			countQuery="select count(*) from ContentUnreviewed where contentType in(3,4) and allotStatus=0 and isApproved in(:status)   ", nativeQuery = false)
	Page<ContentUnreviewed> findContentTask(@Param("status") List<String> status,
			Pageable pageable);

	@Query(value ="select count(*) from ContentUnreviewed where publisherDyId=:dyId  ")
	Integer countTaskByDyId(@Param("dyId") String dyId);

	@Query(value ="select count(*) from ContentUnreviewed where publisherDyId=:dyId and isApproved in (1) ")
	Integer countTaskPassByDyId(@Param("dyId") String dyId);
}
